package org.dl.gjz.menyj.task.service.deletegate;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service("sendTask")
public class SendTask implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) throws Exception {
        System.out.println("sendTask发送消息");
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
            // 这里相当于是 去匹配 【Message Name = Message_task_1】 AND 【BusinessKey=message_business_20250827_01】的接受任务
        runtimeService.createMessageCorrelation("Message_task_1")
                .processInstanceBusinessKey("message_business_20250827_01")
                .setVariable("paymentDate", new Date())
                .correlate();
    }
}
